/*
 * gis_analytics.css — Shared Analytics Stylesheet
 * ──────────────────────────────────────────────────────────────────────────
 * What:    Styles for ATM Analytics UI features: trend sparklines,
 *          competitor vulnerability heatmap, and future analytics overlays.
 * Depends: gis_atm-gis-design-system.css (CSS variables)
 * ──────────────────────────────────────────────────────────────────────────
 */

/* =========================================================================
   ANALYTICS DRAWER — Right-side slide-out panel
   ========================================================================= */

.analytics-drawer {
    position: fixed;
    right: 0;
    top: 60px;
    width: min(380px, 100vw);
    height: calc(100vh - 60px);
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-color);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 42;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

.analytics-drawer.open {
    transform: translateX(0);
}

.analytics-drawer .drawer-header {
    padding: 20px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.analytics-drawer .drawer-title {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analytics-drawer .drawer-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.analytics-drawer .drawer-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

.analytics-drawer .drawer-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}


/* =========================================================================
   ANALYTICS CARD — Glassmorphism card inside drawers / panels
   ========================================================================= */

.analytics-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.analytics-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
}


/* =========================================================================
   ANALYTICS BADGE — Status pill (green / amber / red)
   ========================================================================= */

.analytics-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--hex-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}


/* =========================================================================
   ANALYTICS SPARKLINE — Chart.js canvas container
   ========================================================================= */

.analytics-sparkline-container {
    width: 100%;
    height: 120px;
    position: relative;
    margin: 8px 0 12px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.analytics-sparkline-container canvas {
    width: 100% !important;
    height: 100% !important;
}


/* =========================================================================
   ANALYTICS WARNING — Amber warning banner
   ========================================================================= */

.analytics-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 6px;
    margin: 8px 0;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--accent-orange);
    line-height: 1.5;
}

.analytics-warning .warning-icon {
    flex-shrink: 0;
    font-size: 14px;
    margin-top: 1px;
}

.analytics-error {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    margin: 8px 0;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}


/* =========================================================================
   ANALYTICS STAT — Key-value stat row
   ========================================================================= */

.analytics-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.analytics-stat:last-child {
    border-bottom: none;
}

.analytics-stat .stat-label {
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--text-muted);
}

.analytics-stat .stat-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}


/* =========================================================================
   ANALYTICS SECTION TITLE — Section header inside drawers
   ========================================================================= */

.analytics-section-title {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 16px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.analytics-section-title:first-child {
    margin-top: 0;
}


/* =========================================================================
   ANALYTICS CHIP — Small tag/chip for outliers
   ========================================================================= */

.analytics-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 10px;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    white-space: nowrap;
}

.chip-downtime {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.chip-competitive {
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-orange);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.chip-environmental {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.chip-unexplained {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-dim);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.chip-structural {
    background: rgba(6, 182, 212, 0.12);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.2);
}


/* =========================================================================
   COMPETITOR SUMMARY — Top stats bar in competitor drawer
   ========================================================================= */

.competitor-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.competitor-summary .summary-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 10px 12px;
    text-align: center;
}

.competitor-summary .summary-stat .stat-number {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.competitor-summary .summary-stat .stat-desc {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}


/* =========================================================================
   COMPETITOR ITEM — List item in competitor drawer
   ========================================================================= */

.competitor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.competitor-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-light);
}

.competitor-item .comp-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.competitor-item .comp-info {
    flex: 1;
    min-width: 0;
}

.competitor-item .comp-name {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.competitor-item .comp-city {
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-dim);
}

.competitor-item .comp-score {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}


/* =========================================================================
   VULNERABILITY BAR — Horizontal component bar
   ========================================================================= */

.vuln-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.vuln-bar-label {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--text-muted);
    width: 80px;
    flex-shrink: 0;
}

.vuln-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.vuln-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.vuln-bar-value {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-main);
    width: 36px;
    text-align: right;
    flex-shrink: 0;
}


/* =========================================================================
   TREND SECTION — Inside data-panel
   ========================================================================= */

#trend-section {
    padding: 0 20px 16px;
    animation: analyticsFadeIn 0.3s ease;
}

#trend-section .trend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

#trend-section .trend-legend {
    display: flex;
    gap: 12px;
    margin-top: 6px;
    flex-wrap: wrap;
}

#trend-section .legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-ui);
    font-size: 10px;
    color: var(--text-dim);
}

#trend-section .legend-swatch {
    width: 12px;
    height: 3px;
    border-radius: 1px;
}


/* =========================================================================
   ANALYTICS DETAIL — Back navigation in drawer
   ========================================================================= */

.analytics-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.analytics-back-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--hex-blue);
    color: var(--hex-blue);
}


/* =========================================================================
   ANIMATIONS
   ========================================================================= */

@keyframes analyticsPulse {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.8; }
}

@keyframes analyticsFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.analytics-skeleton {
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.04) 25%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 75%
    );
    background-size: 200% 100%;
    animation: analyticsPulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}


/* =========================================================================
   LEAFLET POPUP OVERRIDES — Analytics-specific popups
   ========================================================================= */

.competitor-popup .leaflet-popup-content-wrapper {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-ui);
}

.competitor-popup .leaflet-popup-tip {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
}

.competitor-popup .popup-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
}

.competitor-popup .popup-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 2px 0;
}

.competitor-popup .popup-row .label {
    color: var(--text-muted);
}

.competitor-popup .popup-row .value {
    font-family: var(--font-mono);
    font-weight: 600;
}

.competitor-popup .popup-link {
    display: block;
    margin-top: 8px;
    padding: 5px 0;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--hex-blue);
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    transition: color 0.2s;
}

.competitor-popup .popup-link:hover {
    color: #60a5fa;
}

/* Panel-specific styles split into gis_analytics_panels.css (Phase 4) */

